package com.example.aslongastoday;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import android.os.Bundle;
import android.widget.Toast;

import com.example.aslongastoday.bean.BeanFactory;
import com.example.aslongastoday.databinding.ActivityMainBinding;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        BeanFactory.addBean("mainActivity",this);

        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        //去除没用的顶栏
        if (getSupportActionBar()!=null){
            getSupportActionBar().hide();
        }

        BottomNavigationView navView = findViewById(R.id.nav_view);
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_backlog, R.id.navigation_tomato_clock, R.id.navigation_reminiscence, R.id.navigation_mine
                ).build();
        //设置控制器
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
        //设置操作栏
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);

        NavigationUI.setupWithNavController(binding.navView, navController);
    }

    @Override
    protected void onResume() {
        super.onResume();
        //测试添加待办组后是否是返回到了MainActivity，结果是并不是。
//        Toast.makeText(this, "onResume, MainActivity", Toast.LENGTH_SHORT).show();
    }
}